package me.send.data.service.provider;

import java.util.Map;

import me.send.business.base.Pager;

public class BrokerWalletLogProvider {
    
    public String list(Map<String, Object> param) {
    	String sql = "select telephone,broker_wallet_log.* from broker_wallet_log left join popuser on broker_wallet_log.brokerId=popuser.popid  where 1=1";
    	if (param != null) {
    		String phone = (String) param.get("phone");
    		String start=(String) param.get("start");
    		Integer payWay=(Integer) param.get("payWay");
    		String end=(String) param.get("end");
    		Pager page=(Pager) param.get("page");
    		if (phone!=null&&!phone.equals("")) {
    			sql += " and telephone=" + phone;
    		}
    		if (payWay!=null&&payWay >= 0) {
    			if(payWay==0){//提现
    				sql += " and broker_wallet_log.orderId is NULL ";
    			}else if(payWay==1){//赚取
    				sql += " and broker_wallet_log.orderId is NOT NULL ";
    			}
    		}
    		
    		if(start!=null&&!start.equals("")){
    			sql+=" and broker_wallet_log.changeTime>='"+start+"'";
    		}
    		if(end!=null&&!end.equals("")){
    			sql+=" and broker_wallet_log.changeTime<'"+end+"'";
    		}
    		sql += " limit " + page.getStart() + "," + page.getRows();
    	}
    	return sql;
    }
    
    public String count(Map<String, Object> param) {
    	String sql = "select count(1) from broker_wallet_log left join popuser on broker_wallet_log.brokerId=popuser.popid  where 1=1";
    	if (param != null) {
    		String phone = (String) param.get("phone");
    		String start=(String) param.get("start");
    		Integer payWay=(Integer) param.get("payWay");
    		String end=(String) param.get("end");
    		if (phone!=null&&!phone.equals("")) {
    			sql += " and telephone=" + phone;
    		}
    		if (payWay!=null&&payWay >= 0) {
    			if(payWay==0){//提现
    				sql += " and broker_wallet_log.orderId is NULL ";
    			}else if(payWay==1){//赚取
    				sql += " and broker_wallet_log.orderId is NOT NULL ";
    			}
    		}
    		
    		if(start!=null&&!start.equals("")){
    			sql+=" and broker_wallet_log.changeTime>='"+start+"'";
    		}
    		if(end!=null&&!end.equals("")){
    			sql+=" and broker_wallet_log.changeTime<'"+end+"'";
    		}
    	}
    	return sql;
    }
    
    
}
